package cn.zcscloud.mall.mbg.mapper;

import cn.zcscloud.mall.mbg.model.SmsCoupon;
import cn.zcscloud.mall.mbg.model.SmsCouponExample;
import java.util.List;

import cn.zcscloud.mall.vo.SmsCouponParamVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

@Mapper
public interface SmsCouponMapper extends BaseMapper<SmsCoupon> {
    @Select("SELECT\n" +
            "\tc.*,\n" +
            "\tcpr.id cpr_id,\n" +
            "\tcpr.product_id cpr_product_id,\n" +
            "\tcpr.product_name cpr_product_name,\n" +
            "\tcpr.product_sn cpr_product_sn,\n" +
            "\tcpcr.id cpcr_id,\n" +
            "\tcpcr.product_category_id cpcr_product_category_id,\n" +
            "\tcpcr.product_category_name cpcr_product_category_name,\n" +
            "\tcpcr.parent_category_name cpcr_parent_category_name \n" +
            "FROM\n" +
            "\tsms_coupon c\n" +
            "\tLEFT JOIN sms_coupon_product_relation cpr ON c.id = cpr.coupon_id\n" +
            "\tLEFT JOIN sms_coupon_product_category_relation cpcr ON c.id = cpcr.coupon_id \n" +
            "WHERE\n" +
            "\tc.id = #{id}")
    SmsCouponParamVo getItem(Long id);
}